import { Logo, Zoom, Scale, Fullscreen, MapTheme, MouseLocation } from '@antv/l7'
export default function useControls(scene, map) {
  const l7Controls = {}
  l7Controls.logo = new Logo({
    href: 'http://www.x-zd.com',
    img: 'http://www.x-zd.com/themes/simpleboot3_web/public/web/images/image/logo_03.png',
  })
  l7Controls.zoom = new Zoom({
    position: 'topleft',
  })
  l7Controls.mouseLocation = new MouseLocation({
    position: 'bottomright',
  })
  l7Controls.fullscreen = new Fullscreen()
  l7Controls.scale = new Scale({
    position: 'bottomright',
  })
  l7Controls.mapTheme = new MapTheme({
    options: [
      {
        text: '白天导航地图',
        value: 'mapbox://styles/mapbox/navigation-day-v1',
        image: '/themes/navigation-day-v1.png',
      },
      {
        text: '夜间导航地图',
        value: 'mapbox://styles/mapbox/navigation-night-v1',
        image: '/themes/navigation-night-v1.png',
      },
      {
        text: '标记卫星图',
        value: 'mapbox://styles/mapbox/satellite-streets-v12',
        image: '/themes/satellite-streets-v12.png',
      },
      {
        text: '普通卫星图',
        value: 'mapbox://styles/mapbox/satellite-v9',
        image: '/themes/satellite-v9.png',
      },
    ],
  })
  for (let key in l7Controls) {
    scene.addControl(l7Controls[key])
  }
  //当zoom级别 大于5的时候 才显示比例尺
  l7Controls.scale.hide()
  map.on('zoom', function () {
    let zoom = map.getZoom()
    if (zoom > 5) {
      l7Controls.scale.show()
    } else {
      l7Controls.scale.hide()
    }
  })
}
